<#include "../base.ftl"/>
<#macro css>

</#macro>

<#macro js>

</#macro>

<#macro title>
广大物流云平台
</#macro>
<#macro script>

function initJqGridHideBtn(){
        $("#add_gridTable").hide();
        $("#edit_gridTable").hide();
        $("#del_gridTable").hide();
    }
    
    function fillVoyageId(){
    	var treeObj=$.fn.zTree.getZTreeObj("shipTree");
        
        var nodes=  treeObj.getSelectedNodes();

        var add_data=new Object();

        var a=nodes[0].id;
       
        a=a.replace("C","");

        add_data["voyageId"]=a;

        add_data["beanName"] = "tsm.TsmLading";
        add_data["status"]='1';
        return add_data;
    
    }


     var setting = {
            async: {
                enable: true,
                url: '${request.contextPath}/admin/shipVoyageTree.action',
                datatype : 'json',
                autoParam:["id","name","level","flag"]
            },
            data: {
                simpleData: {
                       enable: true
                }
            },
            callback:{
                onNodeCreated : zTreeonNodeCreated,
                onClick:zTreeClick
            }
            
        };
 
    function zTreeClick(event,treeId,treeNode){
   
    //var flag=treeNode.FLAG;
      //  alert(flag);
        var a=treeNode.id;
          //alert(a);
          a=a.replace("C","");
          
        //alert(a);
        
            
        
           var b=treeNode.FLAG;
         //alert(b);
         if(b==0){
         //var div=document.getElementById("add_gridTable");
         //div.style.visibility="visible";
         $("#add_gridTable").show();
           $("#edit_gridTable").show();
           $("#del_gridTable").show();
           
            jQuery("#gridTable").jqGrid('setGridParam',{
                url : "${request.contextPath}/list!list.action?voyageId="+a,
                page : 1
            });
             
            //jQuery("#gridTable").navGrid('setGridParam',{
              //  add:false
            //});
            jQuery("#gridTable").trigger('reloadGrid');
            jQuery("#gridPager").trigger('reloadGrid');
            
         }else{
         
           // var div=document.getElementById("add_gridTable");
           // div.style.visibility='hidden'
             //div.style.visibility='visible'
             //style.display="none"
             //style.display=""
            jQuery("#gridTable").jqGrid('setGridParam',{
                url : "${request.contextPath}/list!list.action?voyageId="+a,
                page : 1
            });
            $("#add_gridTable").hide();
            $("#edit_gridTable").hide();
            $("#del_gridTable").hide();
           
            jQuery("#gridTable").trigger('reloadGrid');
            jQuery("#gridPager").trigger('reloadGrid');
            
            
        }
        }
        function zTreeonNodeCreated(event,treeId,treeNode){
        var treeObj=$.fn.zTree.getZTreeObj(treeId);
        var list=treeObj.getNodeByParam("level",'1');
        treeObj.expandNode(list,true,true,true);
     }

        jQuery(document).ready(function(){
            $.fn.zTree.init($("#shipTree"), setting);
        });
        
$(function(){
    $("#gridTable").jqGrid({
    //list表格获取地址
        //list表格数据获取地址
        url:'${request.contextPath}/list!list.action',
        //list表格编辑地址
        editurl :'${request.contextPath}/operator.action',
        datatype: "json",
        mtype:"POST",
        height: 200,
        width: 870,
       colNames:['舱单编号','船舶编号','提单号','订舱号','起运港',
                 '中转港','卸货港','目的港','FDEST','柜号',
                 '封号','柜型','空重','箱属','重量(kg)',
                 '货名','冷柜温度','危品类别','UNNO','超高尺寸',
                 '左超宽尺寸','右超宽尺寸','前超宽尺寸','后超宽尺寸','二程船',
                 '头层船','备注','状态','创建人','创建日期',
                 '最后修改人','最后修改时间'],
        colModel:[
            {name:'ladingId',jsonmap:'LADING_ID',index:'LADING_ID',editable:false,hidden:true},          
            {name:'voyageId',jsonmap:'VOYAGE_ID',index:'VOYAGE_ID',editable:false,hidden:true},     
            {name:'ladingNo',jsonmap:'LADING_NO',editable:true,index:'LADING_NO',editrules:{required:true}},      
            {name:'bookingNo',jsonmap:'BOOKING_NO',editable:true,index:'BOOKING_NO',editrules:{required:true}},
            {name:'dispatchPort',jsonmap:'DISPATCH_PORT',editable:true,index:'DISPATCH_PORT',editrules:{required:true}
            },
            {name:'transShipPort',jsonmap:'TRANSSHIP_PORT',index:'TRANSSHIP_PORT',editable:true,editrules:{required:true}
            },
            {name:'dischargePort',jsonmap:'DISCHARGE_PORT',index:'DISCHARGE_PORT',editable:true,editrules:{required:true}},          
            {name:'destinationPort',jsonmap:'DESTINATION_PORT',index:'DESTINATION_PORT',editable:true,editrules:{required:true}},     
            {name:'fdest',jsonmap:'FDEST',index:'FDEST',editable:true,hidden:true,editrules:{required:true,edithidden:true}},      
            {name:'containerNo',jsonmap:'CONTAINER_NO',editable:true,index:'CONTAINER_NO',editrules:{required:true,edithidden:true},hidden:true},
            {name:'sealNo',jsonmap:'SEAL_NO',index:'SEAL_NO',hidden:true,editrules:{required:true,edithidden:true},editable:true
            },
            {name:'containerType',jsonmap:'CONTAINER_TYPE',editable:true,index:'CONTAINER_TYPE',editrules:{required:true,edithidden:true},hidden:true
            },
            {name:'emptyWeight',jsonmap:'EMPTY_WEIGHT',editable:true,index:'EMPTY_WEIGHT',hidden:true,editrules:{required:true,edithidden:true,number:true}},          
            {name:'containerBelongs',jsonmap:'CONTAINER_BELONGS',index:'CONTAINER_BELONGS',editable:true,hidden:true,editrules:{required:true,edithidden:true}},     
            {name:'weight',jsonmap:'WEIGHT',editable:true,index:'WEIGHT',editrules:{required:true,number:true}},      
            {name:'cargoName',jsonmap:'CARGO_NAME',editable:true,index:'CARGO_NAME',editrules:{required:true}},
            {name:'freezerTemp',jsonmap:'FREEZER_TEMP',editable:true,index:'FREEZER_TEMP',hidden:true,editrules:{required:true,edithidden:true}
            },
            {name:'hazardCategory',jsonmap:'HAZARD_CATEGORY',editable:true,index:'HAZARD_CATEGORY',hidden:true,editrules:{required:true,edithidden:true}},
            {name:'unno',jsonmap:'UNNO',index:'UNNO',editable:true,editrules:{required:true,edithidden:true},hidden:true},          
            {name:'ultrahighSize',jsonmap:'ULTRAHIGH_SIZE',editable:true,index:'ULTRAHIGH_SIZE',hidden:true,editrules:{required:true,edithidden:true,number:true}},     
            {name:'leftUltrawideSize',jsonmap:'LEFT_ULTRAWIDE_SIZE',editable:true,index:'LEFT_ULTRAWIDE_SIZE',hidden:true,editrules:{required:true,edithidden:true,number:true}},      
            {name:'rightUltrawideSize',jsonmap:'RIGHT_ULTRAWIDE_SIZE',editable:true,index:'RIGHT_ULTRAWIDE_SIZE',hidden:true,editrules:{required:true,edithidden:true,number:true}},
            {name:'frontUltrawideSize',jsonmap:'FRONT_ULTRAWIDE_SIZE',editable:true,index:'FRONT_ULTRAWIDE_SIZE',hidden:true,editrules:{required:true,edithidden:true,number:true}
            },
            {name:'afterUltrawideSize',jsonmap:'AFTER_ULTRAWIDE_SIZE',editable:true,index:'AFTER_ULTRAWIDE_SIZE',hidden:true,editrules:{required:true,edithidden:true,number:true}
            },
            {name:'secondVessel',jsonmap:'SECOND_VESSEL',editable:true,index:'SECOND_VESSEL',hidden:true,editrules:{required:true,edithidden:true}},          
            {name:'firstVessel',jsonmap:'FIRST_VESSEL',editable:true,index:'FIRST_VESSEL',hidden:true,editrules:{required:true,edithidden:true}},   
            {name:'remark',jsonmap:'REMARK',index:'REMARK',editable:true,editrules:{required:true}},
            {name:'status',jsonmap:'STATUS',index:'STATUS',editable:false,hidden:true
              
            },
            {name:'createdBy',jsonmap:'CREATED_BY',editable:false,hidden:true},
            {name:'createdDate',jsonmap:'CREATED_DATE',editable:false,hidden:true,
                editoptions :  {dataInit: function(element) {
                    $(element).datepicker({changeMonth : true,changeYear : true,dateFormat : 'yy-mm-dd'});
                }}       
            },
            {name:'lastUpdBy',jsonmap:'LAST_UPD_BY',editable:false,hidden:true},
            {name:'lastUpdDate',jsonmap:'LAST_UPD_DATE',editable:false,hidden:true,
              editoptions :  {dataInit: function(element) {
                    $(element).datepicker({changeMonth : true,changeYear : true,dateFormat : 'yy-mm-dd'});
                }}  
            }     
        ],
        sortname:'LADING_ID',
        sortorder:'ASC',
        viewrecords : true,
        gridview : true,
        rownumbers : true,
        rowNum : 20,
        altRows:true,
        rowList : [10,20,30],
        //onSelectRow:cellSelect,
        jsonReader : {
            page : "page.pageNo",
            total : "page.totalPages",
            records : "page.totalCount",
            root : "page.result",
            repeatitems : false,
            id : 'LADING_ID'
        },
        
        prmNames : {
            rows : "page.pageSize",
            page : "page.pageNo",
            sort : "page.orderBy",
            order : "page.order"
        },
        loadBeforeSend : function(xhr,settings){
            //设置访问的list标签
            settings.data=settings.data+ "&gridKey=/list/operation#TsmLading";
            return true;
        },
        pager : "#gridPager",
        caption : "作业计划列表"
    }).navGrid('#gridPager',{
            add:true,
            edit:true,
            //editfunc:editVoyage,
            //addfunc:addVoyage,
            del:true, 
            //delfunc:delVoyage,
            search: false
    },{ 
        //edit
        //beforeSubmit:cellSelect,
        reloadAfterSubmit:true,
        closeAfterEdit:true,//新增完毕后关闭
        afterComplete:opertaionPrompt,//更新结束后提示信息
        onclickSubmit: fillVoyageId , //触发的事件
        //beforeSubmit:cellSelect
    },{
    //add
        //beforeSubmit:cellSelect,
        reloadAfterSubmit : true,
        closeAfterAdd : true, //新增完毕后关闭
        afterComplete : opertaionPrompt,
        onclickSubmit: fillVoyageId
    },{
      //del
        reloadAfterSubmit : true, 
        closeAfterEdit : true,  //修改完毕后关闭
        afterComplete : opertaionPrompt, //更新结束后提示信息
        onclickSubmit: fillVoyageId 
        
    })
    initJqGridHideBtn();
});
        
        
        
        
        
        
        
        
        
        
</#macro>

<#macro main>

  <div id="treediv" class="ui-widget-content ui-corner-all" style="margin:30px 10px 20px -30px;float:left;width:250px;">
           <ul id="shipTree" class="ztree"></ul>
  </div>
  <div id="detaildiv" style="background-color:Navy;margin:30px 10px 20px -10px;float:left;width:200px;">
           <table id="gridTable"></table>
           <div id="gridPager"></div>
  </div>
 
</#macro>